<<template>
    <div>
    111
    {{qxlist[0].rname}}--{{qxlist[0].uname}}--
    <br />
        <el-checkbox v-for="(item, index) in qxlist[0].plist" :key="index" :label="item.aname" ></el-checkbox>
        222
        <hr />
        <h1>所有权限</h1>
        <!-- <el-checkbox v-for="(item, index) in qclist" :key="index" :label="item.name" :checked="item.checked" :title="item.path" ></el-checkbox> -->
        <el-checkbox v-for="(item, index) in qclist" :key="index" :label="item.name" v-model="qylist" :value="item.name"></el-checkbox>
        <el-button type="primary" @click="abc">提交</el-button>
    </div>
</template>
<script>
import { getAllList, updatequanxian } from '@/api/quanxian'
import { mapGetters } from 'vuex'

export default {
    data() {
        return {
            qclist: [],
            qylist: []
        }
    },
    computed: {
        ...mapGetters([
        'qxlist'
        ])
    },
    methods: {
        abc() {
            // 不对应该修改vuex
          let data = {username: 'mazheng', qylist: this.qylist}
          updatequanxian(data).then((res) => {
            this.$message({
                showClose: true,
                message: '恭喜你，修改成功消息',
                type: 'success',
                duration: 2000
            });
          })
        }
    },
    async created() {
        let _this = this
        debugger
        await this.$store.dispatch("quanxian/getList", {uname: 'mazheng'}).then(() => {
            console.info(_this)
           
        })
        debugger
 
        getAllList().then((res) => {

                this.qclist = res.data
                
                for (let i = 0; i < this.qxlist[0].plist.length; i++) {
                    for (let j =0; j < this.qclist.length; j++) {
                            if (this.qxlist[0].plist[i].aname == this.qclist[j].name) {
                                this.qclist[j].checked = true
                                this.qylist.push(this.qclist[j].name)
                            }
                    }
                }
            

            })
        

    }
}
</script>